package com.henry.read;


import com.tools.hry.xls.AnalysisXlsTool;
import com.tools.hry.xls.CreateXlsTool;
import com.tools.hry.xls.analysis.AnalysisResult;
import com.tools.hry.xls.analysis.ICallbackFunction;
import com.tools.hry.xls.analysis.util.ReadExcelUtils;
import com.tools.hry.xls.create.CreateResult;
import com.tools.hry.xls.create.IWriteCallbackFunction;

import java.io.FileInputStream;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by 峥桂 on 2017/1/12.
 */
public class Test {
    public static void main(String agrs[]) throws Exception {

        ReadExcelUtils readExcelUtils = new ReadExcelUtils();
        long start = new Date().getTime();
        try {
            readExcelUtils.readExcel(new FileInputStream("e://非卡单1-3月.xls"), 0, 0,false);
            System.out.println(readExcelUtils.getDatas().length);
            System.out.println("end="+(new Date().getTime()-start));
        }catch (Exception e){
            e.printStackTrace();
        }


//        analysis();
    }

    public static void analysis1()throws Exception{
        AnalysisXlsTool.readInputStreamAndToEntity(new FileInputStream("d:\\DB20170204_1.xls"), ClaimInfo.class
                , 0, 0, new ICallbackFunction<ClaimInfo>() {
                    public void onFailure(AnalysisResult result) throws Exception {
                        System.out.println("===onFailure=====");
                        System.out.println(result.getErrorLogBeans());
                        System.out.println(result.getException().getMessage());
                    }

                    public void onSuccess(AnalysisResult result, List resultList) throws Exception {

                    }

                    public void before(AnalysisResult result) throws Exception {

                    }

                    public void after(AnalysisResult result) throws Exception {

                    }
                });
    }
    public static void analysis()throws Exception{
        List<ClaimsExcelBean> list=null;//ExcelAndCsvUtils.readFileAndToEntitys("d:\\结案模板.xlsx",ClaimsExcelBean.class);
        AnalysisXlsTool.readInputStreamAndToEntity(new FileInputStream("d:\\template1.xlsx"),
                ClaimsExcelBean.class,0,0,new ICallbackFunction<ClaimsExcelBean>() {
                    public void onFailure(AnalysisResult excelUtil) throws Exception {
                        System.out.println("===onFailure=====");
                        System.out.println(excelUtil.getErrorLogBeans());
                        System.out.println(excelUtil.getException().getMessage());
                        //  if(e!=null){
                        //  throw e;
                        //  }
                    }
                    public void onSuccess(AnalysisResult excelUtil, List<ClaimsExcelBean> list_) throws Exception {
                        System.out.println("=====onSuccess===");
                        System.out.println(excelUtil.getErrorLogBeans());
                        for (ClaimsExcelBean bean:list_) {
                            System.out.println(bean.toString());
                        }
                    }
                    public void before(AnalysisResult excelUtil) throws Exception {
                    }



                    public void after(AnalysisResult result) throws Exception {

                    }
                });

    }
}
